'''
Author: WangGuojian 1085844536@qq.com
Date: 2024-08-28 20:25:06
LastEditTime: 2024-08-28 20:29:22
LastEditors: WangGuojian 1085844536@qq.com
FilePath: \demod:\Developer\WGJ\VSCode_WorkSpace\Python\办公自动化\源码笔记\demo05.py
Description:
'''
# 对齐方式
from docx import Document
from docx.enum.text import WD_PARAGRAPH_ALIGNMENT

document = Document()
paragraph = document.add_paragraph()

print(paragraph.alignment)    # --> None：表示对齐方式是从样式层次中继承的

paragraph_format = paragraph.paragraph_format
print(paragraph_format.alignment)   # --> None：表示对齐方式是从样式层次中继承的


paragraph.alignment = WD_PARAGRAPH_ALIGNMENT.CENTER
print(paragraph.alignment)    # --> CENTER (1)

paragraph.add_run('这是一个段落，请看对齐方式')

document.save('修改段落对齐.docx')


